from flask_marshmallow import base_fields
from flask_restplus_patched import ModelSchema
from app.modules.common.schemas import BaseSchema
from .models import PostponeRecord


class PostponeRecordBaseSchema(ModelSchema):
    class Meta:
        model = PostponeRecord
        fields = (
            'id',
            'create_date',
            'postpone_user_id',
            'postpone_user_name',
            'apply_id',
            'agent_ip',
            'from_date',
            'to_date',
            'plan_name',
            'desc',
        )

        dump_only = (
            "id",
        )


class PostponeRecordListSchema(BaseSchema):
    data = base_fields.Nested(
        PostponeRecordBaseSchema,
        many = True
    )

    class Meta:
        fields = BaseSchema.Meta.fields + (
            'data',
        )
